package com.db.test.listener;

import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component("tListener")
public class TListener implements TaskListener ,ApplicationEventPublisherAware {

    private ApplicationEventPublisher applicationEventPublisher;

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.applicationEventPublisher = applicationEventPublisher;
    }

    @Override
    public void notify(DelegateTask delegateTask) {
        Map<String,Object> param = delegateTask.getVariables();
        System.out.println(param);
        applicationEventPublisher.publishEvent(new MyApplicationEvent(param));
    }
}
